#ifndef NANE_LOG_H
#   define NANE_LOG_H

#   include "nane/core/crt/LogManager.h"
#   include "nane/core/assert.h"
#   include "nane/core/stackstring.h"

#   define NANE_MAX_LOGMESSAGE_LENGTH 256

namespace nane
{
    typedef StackString<NANE_MAX_LOGMESSAGE_LENGTH> TLogString;

    class StackStringLogger
    {
    public:
        StackStringLogger( const char* _message, const char* _file, const char* _line, const char* _function, ELogMessageLevel _messageLevel )
            : m_message( _message )
            , m_file( _file )
            , m_line( _line )
            , m_function( _function )
            , m_messageLevel( _messageLevel )
        {

        }
        ~StackStringLogger()
        {
            LogManager::Log(m_message.c_str(), m_file, m_line, m_function, m_messageLevel);
        }

        template<typename T>
        StackStringLogger& operator<<( T _value )
        {
            m_message << _value;
            return *this;
        }
    private:
        TLogString m_message;
        const char* m_file;
        const char* m_line;
        const char* m_function;
        ELogMessageLevel m_messageLevel;
    };

}   // namespace nane

#    define LOG_ERROR( _message )    nane::StackStringLogger( _message, __FILE__, TOSTRING( __LINE__ ) , __FUNCTION__, nane::ELogMessageLevel::Error )
#    define LOG_WARNING( _message )  nane::StackStringLogger( _message, __FILE__, TOSTRING( __LINE__ ) , __FUNCTION__, nane::ELogMessageLevel::Warning )
#    define LOG_INFO( _message )     nane::StackStringLogger( _message, __FILE__, TOSTRING( __LINE__ ) , __FUNCTION__, nane::ELogMessageLevel::Info )
#    define LOG_DEBUG( _message )     nane::StackStringLogger( _message, __FILE__, TOSTRING( __LINE__ ) , __FUNCTION__, nane::ELogMessageLevel::Debug )

#endif	// NANE_LOG_H
